//
//  FetchMusicViewModel.swift
//  ExtremeHealth
//
//  Created by Zhongkai Li 李忠凯 on 2018/9/29.
//  Copyright © 2018 GanDongKeJi. All rights reserved.
//

import RxSwift
import Toast

struct FetchMusicViewModel {
    func fetch(category: String = "",
               disposeBag: DisposeBag,
               completionClosure: @escaping (SleepAidMusic) -> Void) {
        Network.request(target: .fetchMusic(category: category),
        success: { (obj: SleepAidMusic) in
            completionClosure(obj)
        }, failure: { (moyaError) in
            EHToast.show(moyaError.localizedDescription)
        }, error: { (error) in
            EHToast.show(error)
        }, dispose: disposeBag)
    }
}
